package com.lhx.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;


public class Test {
    @org.junit.jupiter.api.Test
    public void testUpdate() throws ClassNotFoundException {
        //注册驱动
        Class.forName("com.mysql.cj.jdbc.Driver");
        //获取连接
        try {
            Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/web01", "root", "123456");
            //获取SQL语句执行对象
            Statement statement = connection.createStatement();

            //执行SQL语句
            int update = statement.executeUpdate("update user set password = 123456 where id = 5");
            //释放资源
            statement.close();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }




    }
}
